package com.dragon.smtp;

import java.net.InetAddress;
import java.net.UnknownHostException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

@SpringBootApplication
public class SmtpApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext run = SpringApplication.run(SmtpApplication.class, args);
        //返回项目启动的网址
        Environment env = run.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if(path == null){
            path = "";
        }
        System.out.println("\n----------------------------------------------------------\n\t" +
            "Application  is running! Access URLs:\n\t" +
            "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
            "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" +
            "----------------------------------------------------------");
    }

}
